<?php
namespace app\api\controller;
use think\Request;
use app\api\controller\Base;
use app\api\model\UserGoods as MGoods;

/**
 * @title goods 商品相关信息接口|[客户端]
 * @description 与商品相关信息
 */
 
class UserGoods extends Base
{
    /**
     * @title goods/category 获取商品分类信息 GET
     * @description 说明：获取商品分类信息 
     * @author 虾哥@2424899422@qq.com
     * @url goods/category/
	 * @Turl api/user_goods/category
	 
	 * @return lists:地址列表|参考备注信息@
     * @lists goods_cat_id:商品分类自增ID  parent_id:商品分类父id is_show:是否显示 cat_name:分类名称 cat_id:分类图标 cat_sort:分类排序 
	 *
	 * @remark 返回示例
     */
    public function category($user_id,$page,$length)
    {
		
		$return = array('code' => 0, 'message' => 'query goods list success !', 'data' => array());
		$data = MGoods::lists($user_id,$page,$length);
		if (empty($data)) {
            $return['code'] = 1;
            $return['message'] = 'query goods list failed !';
            return $return;
        }
        $return['data']['list'] = $data;
		return json($return);	
    }
	
	/**
     * @title goods/list 查询商品相关信息 GET
     * @description 说明：依据 type_id 查询商品相关信息 
     * @author 虾哥@2424899422@qq.com
     * @url goods/list/
	 * @Turl api/user_goods/lists
     *
	 * @param name:type_id type:int require:1 default:null desc:获取类型：1-首页推荐2-首页活动推荐3-内页推荐4-热销商品5-最新商品6-随机推荐 
	 * @param name:page type:int require:0 default:1 other: desc:当前页ID
	 * @param name:length type:int require:0 default:4 other: desc:当前页显示数量
	 *
	 * 
     */
    public function lists($type_id,$page,$length)
    {
		
		$return = array('code' => 0, 'message' => 'query goods list success !', 'data' => array());
		$data = MGoods::lists($type_id,$page,$length);
		if (empty($data)) {
            $return['code'] = 1;
            $return['message'] = 'query goods list failed !';
            return $return;
        }
        $return['data']['list'] = $data;
		return json($return);	
    }
	
	/**
     * @title goods/search 查询商品相关信息 GET
     * @description 说明：依据 search 查询商品相关信息 
     * @author 虾哥@2424899422@qq.com
     * @url goods/search/
	 * @Turl api/user_goods/search
     *
	 * @param name:keywords type:int require:1 default:null desc:输入的关键字
	 * @param name:page type:int require:0 default:1 other: desc:当前页ID
	 * @param name:length type:int require:0 default:4 other: desc:当前页显示数量
	 *
	 * 
     */
    public function search($keywords,$page,$length)
    {
		
		$return = array('code' => 0, 'message' => 'query goods list success !', 'data' => array());
		$data = MGoods::search($keywords,$page,$length);
		if (empty($data)) {
            $return['code'] = 1;
            $return['message'] = 'query goods list failed !';
            return $return;
        }
        $return['data']['list'] = $data;
		return json($return);	
    }


	/**
     * @title goods/filter 过滤某一分类的属性列表 GET
     * @description 说明：依据 cat_id 过滤某一分类的属性列表 
     * @author 虾哥@2424899422@qq.com
     * @url goods/filter/
	 * @Turl api/user_goods/filter
     *
	 * @param name:cat_id type:int require:1 default:null desc:某一分类的类型id
	 * @param name:page type:int require:0 default:1 other: desc:当前页ID
	 * @param name:length type:int require:0 default:4 other: desc:当前页显示数量
	 *
	 * 
     */
    public function filter($cat_id,$page,$length)
    {
		
		$return = array('code' => 0, 'message' => 'query goods list success !', 'data' => array());
		$data = MGoods::filter($cat_id,$page,$length);
		if (empty($data)) {
            $return['code'] = 1;
            $return['message'] = 'query goods list failed !';
            return $return;
        }
        $return['data']['list'] = $data;
		return json($return);	
    }
	
    /**
     * @title goods/detail 获取单一商品页 GET
     * @description 依据 goods_id 获取单一商品页
	 * @author 虾哥@2424899422@qq.com
	 * @url goods/detail/
	 * @Turl api/user_goods/detail
	  
	 * @param name:goods_id type:int require:1 default:null other: desc:收货地址自增ID
	 
	 * @return lists:地址详情@
     * @lists goods_id:收货地址自增ID  user_name:收货人姓名 user_tel:收货人手机号码 user_phone:收货人电话号码 province_id:收货人省份id city_id:收货人市id country_id:收货人区县id goods:收货人详细地址  post_code:收货人邮编 
	 
     */
    public function detail($goods_id) {
       $return = array('code' => 0, 'message' => 'get adress detail success !', 'data' => array());
		$data = MGoods::addressInfo($goods_id);
		if (empty($data)) {
            $return['code'] = 1;
            $return['message'] = 'get adress detail failed！';
            return $return;
        }
        $return['data']['list'] = $data;
		return json($return);	
    }
	
	 /**
     * @title goods/description 获取商品详情页 GET
     * @description 依据 goods_id 获取商品详情页
	 * @author 虾哥@2424899422@qq.com
	 * @url goods/description/
	 * @Turl api/user_goods/description
	  
	 * @param name:goods_id type:int require:1 default:null other: desc:收货地址自增ID
	 
	 * @return lists:地址详情@
     * @lists goods_id:收货地址自增ID  user_name:收货人姓名 user_tel:收货人手机号码 user_phone:收货人电话号码 province_id:收货人省份id city_id:收货人市id country_id:收货人区县id goods:收货人详细地址  post_code:收货人邮编 
	 
     */
    public function description($goods_id) {
       $return = array('code' => 0, 'message' => 'get adress detail success !', 'data' => array());
		$data = MGoods::addressInfo($goods_id);
		if (empty($data)) {
            $return['code'] = 1;
            $return['message'] = 'get adress detail failed！';
            return $return;
        }
        $return['data']['list'] = $data;
		return json($return);	
    }
	
  
	


}
